//
//  UINavigationController+JKExtension.m
//  Category
//
//  Created by jamalping on 16/4/6.
//  Copyright © 2016年 jamalping. All rights reserved.
//

#import "UINavigationController+JKExtension.h"

@implementation UINavigationController (JKExtension)

// 导航控制器移除某个控制器
-(void)removeViewController:(UIViewController*)controller
{
    NSMutableArray *array = [self.viewControllers mutableCopy];
    [array removeObject:controller];
    [self setViewControllers:array];
}

- (void)pushViewController:(UIViewController *)controller withTransition:(UIViewAnimationTransition)transition {
    [UIView beginAnimations:nil context:NULL];
    [self pushViewController:controller animated:NO];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationTransition:transition forView:self.view cache:YES];
    [UIView commitAnimations];
}

- (UIViewController *)popViewControllerWithTransition:(UIViewAnimationTransition)transition {
    [UIView beginAnimations:nil context:NULL];
    UIViewController *controller = [self popViewControllerAnimated:NO];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationTransition:transition forView:self.view cache:YES];
    [UIView commitAnimations];
    return controller;
}

@end
